using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Abp.Threading.BackgroundWorkers;
using L._52ABP.Core.Modules;
using JYJ.AiYard.Authorization;
using JYJ.AiYard.Authorization.Permissions.Dtos.CustomMapper;
 
using JYJ.AiYard.Editions.Mapper;
using JYJ.AiYard.Languages.Dtos.CustomMapper;
using JYJ.AiYard.MultiTenancy.Mapper;
using JYJ.AiYard.Organizations.Dtos.CustomMapper;
using JYJ.AiYard.PhoneBooks.Books.Authorization;
using JYJ.AiYard.PhoneBooks.Books.Mapper;
using JYJ.AiYard.StationManagement.TbAlipayParams.Authorization;
using JYJ.AiYard.StationManagement.TbAlipayParams.Mapper;


using JYJ.AiYard.StationManagement.TbVipParams.Authorization;
using JYJ.AiYard.StationManagement.TbVipParams.Mapper;

using JYJ.AiYard.StationManagement.TbCCBPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbCCBPayParams.Mapper;

using JYJ.AiYard.StationManagement.TbRoadPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbRoadPayParams.Mapper;
using JYJ.AiYard.StationManagement.TbCIBPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbCIBPayParams.Mapper;


using JYJ.AiYard.StationManagement.TbFFPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbFFPayParams.Mapper;

using JYJ.AiYard.StationManagement.TbYIDEINVParams.Authorization;
using JYJ.AiYard.StationManagement.TbYIDEINVParams.Mapper;

using JYJ.AiYard.StationManagement.TbJLPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbJLPayParams.Mapper;
using JYJ.AiYard.StationManagement.TbFuiouPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbFuiouPayParams.Mapper;

using JYJ.AiYard.StationManagement.TbClientRegisters.Authorization;
using JYJ.AiYard.StationManagement.TbClientRegisters.Mapper;
using JYJ.AiYard.StationManagement.TbDeparts.Authorization;
using JYJ.AiYard.StationManagement.TbDeparts.Mapper;
using JYJ.AiYard.StationManagement.TbDiscountBills.Authorization;
using JYJ.AiYard.StationManagement.TbDiscountBills.Mapper;
using JYJ.AiYard.StationManagement.TbMicroPayParams.Authorization;
using JYJ.AiYard.StationManagement.TbMicroPayParams.Mapper;
using JYJ.AiYard.StationManagement.TbObjects.Authorization;
using JYJ.AiYard.StationManagement.TbObjects.Mapper;
using JYJ.AiYard.StationManagement.TbSales.Authorization;
using JYJ.AiYard.StationManagement.TbSales.Mapper;
using JYJ.AiYard.StationManagement.TbStations.Mapper;
using JYJ.AiYard.StationManagement.TbUser.Authorization;
using JYJ.AiYard.StationManagement.TbUser.Mapper;
using JYJ.AiYard.StationManagement.TbYardBlackLists.Authorization;
using JYJ.AiYard.StationManagement.TbYardBlackLists.Mapper;
using JYJ.AiYard.StationManagement.TbYardLovingLists.Authorization;
using JYJ.AiYard.StationManagement.TbYardLovingLists.Mapper;
using JYJ.AiYard.StationManagement.TbYardDevices.Authorization;
using JYJ.AiYard.StationManagement.TbYardDevices.Mapper;

using JYJ.AiYard.StationManagement.TbYardPayDayNights.Authorization;
using JYJ.AiYard.StationManagement.TbYardPayDayNights.Mapper;
using JYJ.AiYard.StationManagement.TbYardPayDayNightNFs.Authorization;
using JYJ.AiYard.StationManagement.TbYardPayDayNightNFs.Mapper;
using JYJ.AiYard.StationManagement.TbYardPayMonthCards.Authorization;
using JYJ.AiYard.StationManagement.TbYardPayMonthCards.Mapper;
using JYJ.AiYard.StationManagement.TbYardIssuedCards.Authorization;
using JYJ.AiYard.StationManagement.TbYardIssuedCards.Mapper;
using JYJ.AiYard.StationManagement.TbYardLocalFrees.Authorization;
using JYJ.AiYard.StationManagement.TbYardLocalFrees.Mapper;
using JYJ.AiYard.StationManagement.TbYardMonthCardOnlines.Authorization;
using JYJ.AiYard.StationManagement.TbYardMonthCardOnlines.Mapper;
using JYJ.AiYard.StationManagement.TbYardPayNormals.Authorization;
using JYJ.AiYard.StationManagement.TbYardPayNormals.Mapper;
using JYJ.AiYard.StationManagement.TbYardStations.Authorization;
using JYJ.AiYard.StationManagement.TbYardStations.Mapper;
using JYJ.AiYard.StationManagement.TbYardUserParkings.Authorization;
using JYJ.AiYard.StationManagement.TbYardUserParkings.Mapper;
using JYJ.AiYard.WechatManagement.WechatAppConfigs.Authorization;
using JYJ.AiYard.WechatManagement.WechatAppConfigs.Mapper;
using JYJ.AiYard.WechatManagement.WechatMenus.Mapper;
using JYJ.AiYard.StationManagement.TbYardParamsSets.Mapper;
using JYJ.AiYard.StationManagement.TbYardParamsSets.Authorization;
using JYJ.AiYard.StationManagement.YardReport.Authorization;
using JYJ.AiYard.StationManagement.TbStationStatus.Authorization;
using JYJ.AiYard.StationManagement.TbStationStatus.Mapper;
using JYJ.AiYard.StationManagement.TbDigitalPaychk.Authorization;
using JYJ.AiYard.StationManagement.TbDigitalPaychk.Mapper;
using JYJ.AiYard.StationManagement.TbXiaoJuParams.Authorization;
using JYJ.AiYard.StationManagement.TbXiaoJuParams.Mapper;
using JYJ.AiYard.StationManagement.TbPPPayParams.Mapper;
using JYJ.AiYard.StationManagement.TbPPPayParams.Authorization;
using JYJ.AiYard.StationManagement.TvDigitalPay.Authorization;
using JYJ.AiYard.StationManagement.TvDigitalPay.Mapper;
using JYJ.AiYard.StationManagement.TbSUZUploads.Authorization;
using JYJ.AiYard.StationManagement.TbSUZUploads.Mapper;

namespace JYJ.AiYard {
    [DependsOn (
        typeof (AiYardCoreModule),
        typeof (AbpAutoMapperModule))]
    public class AiYardApplicationModule : AbpModule {
        public override void PreInitialize () {          

            // 权限认证提供者
            Configuration.Authorization.Providers.Add<AppProAuthorizationProvider> ();

            // ================== Wechat模块权限 =====================
            Configuration.Authorization.Providers.Add<WechatAppConfigAuthorizationProvider> ();

            // ================== Book模块权限 =====================
           
            Configuration.Authorization.Providers.Add<BooksAuthorizationProvider>();

            //===================Tb_YardDevice模块权限=====================================
            Configuration.Authorization.Providers.Add<TbStationStatusAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbDigitalPaychkAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TvDigitalPayAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<Tb_YardDeviceAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbUserAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbDepartAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbClientRegisterAuthorizationProvider>();

            Configuration.Authorization.Providers.Add<TbYardPayNormalAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardPayDayNightAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardPayDayNightNFAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardPayMonthCardAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardLocalFreeAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardMonthCardOnlineAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardUserParkingAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardStationAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbObjectsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbMicroPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbCCBPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbCIBPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbFFPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYIDEINVParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbJLPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbFuiouPayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbXiaoJuParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbPPPayParamsAuthorizationProvider>();

            Configuration.Authorization.Providers.Add<TbRoadPayParamsAuthorizationProvider>();

            Configuration.Authorization.Providers.Add<TbAlipayParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbVipParamsAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardBlackListAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardLovingListAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbSaleAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardIssuedCardAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbDiscountBillAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbYardParamsSetAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbrInYardAuthorizationProvider>();
            Configuration.Authorization.Providers.Add<TbSUZUploadAuthorizationProvider>();


            // 自定义类型映射
            Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration =>
            {

                // 系统通用的Dto映射
                CustomerAppDtoMapper.CreateMappings(configuration);

                // 版本
                CustomEditionMapper.CreateMappings(configuration);

                // Add your custom AutoMapper mappings here...

             

                // Permission
                CustomerPermissionsMapper.CreateMappings (configuration);

                // OrganizationUnit
                CustomerOranizationMapper.CreateMappings (configuration);

                            // Tenant
                TenantMapper.CreateMappings (configuration);

                // ================== Wechat =====================
                WechatAppConfigMapper.CreateMappings (configuration);
                WechatMenuMapper.CreateMappings (configuration);

                // ================== Book对象映射 =====================
              
                BookMapper.CreateMappings(configuration);

                TbStationMapper.CreateMappings(configuration);

                //=======================数据库Yard映射部分===========================

                TbStationStatusMapper.CreateMappings(configuration);
                TbDigitalPaychkMapper.CreateMappings(configuration);
                TvDigitalPayMapper.CreateMappings(configuration);
                Tb_YardDeviceMapper.CreateMappings(configuration);
                TbClientRegisterMapper.CreateMappings(configuration);
                TbUserMapper.CreateMappings(configuration);
                TbDepartMapper.CreateMappings(configuration);

                TbMicroPayParamsMapper.CreateMappings(configuration);
                TbCCBPayParamsMapper.CreateMappings(configuration);
                TbCIBPayParamsMapper.CreateMappings(configuration);
                TbFFPayParamsMapper.CreateMappings(configuration);
                TbYIDEINVParamsMapper.CreateMappings(configuration);
                TbJLPayParamsMapper.CreateMappings(configuration);
                TbFuiouPayParamsMapper.CreateMappings(configuration);
                TbXiaoJuParamsMapper.CreateMappings(configuration);
                TbPPPayParamsMapper.CreateMappings(configuration);
                TbRoadPayParamsMapper.CreateMappings(configuration);

                TbAlipayParamsMapper.CreateMappings(configuration);
                TbVipParamsMapper.CreateMappings(configuration);
                TbYardPayNormalMapper.CreateMappings(configuration);
                TbYardPayDayNightMapper.CreateMappings(configuration);
                TbYardPayDayNightNFMapper.CreateMappings(configuration);
                TbYardPayMonthCardMapper.CreateMappings(configuration);
                TbYardLocalFreeMapper.CreateMappings(configuration);
                TbSUZUploadMapper.CreateMappings(configuration);
                TbYardMonthCardOnlineMapper.CreateMappings(configuration);
                TbYardUserParkingMapper.CreateMappings(configuration);
                TbObjectsMapper.CreateMappings(configuration);
                TbYardStationMapper.CreateMappings(configuration);
                TbSaleMapper.CreateMappings(configuration);
                TbYardBlackListMapper.CreateMappings(configuration);
                TbYardLovingListMapper.CreateMappings(configuration);
                TbYardIssuedCardMapper.CreateMappings(configuration);
                TbDiscountBillMapper.CreateMappings(configuration);
                TbYardParamsSetMapper.CreateMappings(configuration);
            });

        }

        public override void Initialize () {
            var thisAssembly = typeof (AiYardApplicationModule).GetAssembly ();

            IocManager.RegisterAssemblyByConvention (thisAssembly);


          


            Configuration.Modules.AbpAutoMapper ().Configurators.Add (
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddProfiles (thisAssembly)
            );
        }

        public override void PostInitialize () {

    

            var workManager = IocManager.Resolve<IBackgroundWorkerManager> ();
            //workManager.Add(IocManager.Resolve<TestAutoLoggerPassiveWorker>());

        }
    }
}